package com.ftg.learn.bus.deptexam.service;

import com.ftg.learn.bus.deptexam.entity.DeptExam;
import com.ftg.learn.bus.deptexam.mapper.DeptExamMapper;
import com.ftg.learn.bus.exam_record.service.ExamRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class DeptExamService {

    @Autowired
    DeptExamMapper dem;

    @Autowired
    ExamRecordService ers;

    /**
     * 查全部
     * @return
     */
    public List<Map<String,Object>> showAll(){
        return dem.showAll();
    }

    /**
     * 查一
     * @param deptexam_id
     * @return
     */
    public List<Map<String,Object>> findOne(String deptexam_id){
        return dem.findOne(deptexam_id);
    }

    /**
     * 修改审核状态
     * @return
     */
    public int update(String expendcar_id,String check_state,String deptexam_id){
        if(findOne(deptexam_id)==null){
            return -1;
        }
        if(!check_state.equals("特殊情况")){
            ers.ExamUpdateRecord(expendcar_id,"审核员");
            delete(deptexam_id);
            return dem.update(check_state,expendcar_id);
        }else{
            return -2;
        }
    }

    /**
     * 删除审核条目（未启用）
     * @param deptexam_id
     * @return
     */
    public int delete(String deptexam_id){
        if(findOne(deptexam_id)==null){
            return -1;
        }
        return dem.delete(deptexam_id);
    }
}
